import sbt.Keys._
import sbt._
import Dependencies._

val commonSettings =
  Seq(
    resolvers ++= Seq(
      Resolver.mavenLocal,
      "TypeSafe Repository" at "http://repo.typesafe.com/typesafe/releases/",
      "sbt Repository" at "https://dl.bintray.com/sbt/sbt-plugin-releases/"
    )
  ) ++
    Seq(
      name := "learning-some",
      version := someVersion,
      scalaVersion := scalaVersionNumber
    )

lazy val akkaClusterClient = (project in file("akka") / "cluster" / "akkademy-client")
  .withId("akkademy-client")
  .settings(
    commonSettings,
    libraryDependencies ++= Seq(akkaActorLib, akkaClusterLib, akkaClusterToolLib)
  )

lazy val akkaClusterServer = (project in file("akka") / "cluster" / "akkademy-server")
  .withId("akkademy-server")
  .settings(
    commonSettings,
    libraryDependencies ++= Seq(akkaActorLib, akkaClusterLib, akkaClusterToolLib, boilerPipeLib)
  )

lazy val enum = (project in file("enum"))
  .withId("enum")
  .settings(
    commonSettings
  )

lazy val mailbox = (project in file("akka") / "mailbox" / "mailbox-demo")
  .withId("mailbox-demo")
  .settings(
    commonSettings,
    libraryDependencies ++= Seq(akkaActorLib, akkaClusterLib, akkaClusterToolLib)
  )

lazy val root = (project in file("."))
  .withId("learning-some")
  .aggregate(nonRoots: _*)
  .settings(commonSettings)

def allProjects =
  Seq(
    akkaClusterClient,
    akkaClusterServer,
    enum,
    mailbox
  )

lazy val nonRoots = allProjects.map(p => LocalProject(p.id))

mappings in (Compile, packageBin) ~= { _.filterNot { case (_, name) =>
  Seq("application.conf").contains(name)
}}